
function useSendVerificationCode() {
  const countNum = ref(0)
  const countInterval = ref(null)

  const startCountDown = num => {
    countNum.value = Number(num)

    clearCountDown()
    countInterval.value = setInterval(() => {
      if (countNum.value === 0) {
        clearInterval(countInterval.value)
        countInterval.value = null
        return
      }
      countNum.value--
    }, 1000)
  }

  const clearCountDown = () => {
    if (countInterval.value) {
      countNum.value = 0
      clearInterval(countInterval.value)
    }
  }
  return { countNum, startCountDown, clearCountDown }
}

export default useSendVerificationCode